package com.lzk.auth.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lzk.auth.service.OrderService;
import com.lzk.common.result.Result;
import com.lzk.model.system.SysOrder;
import com.lzk.vo.system.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "个人订单管理")
@RestController
@RequestMapping("/admin/personal/order")
public class PersonalOrder {
    @Autowired
    private OrderService orderService;

    @ApiOperation("订单条件分页查询")
    @GetMapping("{page}/{limit}")
    public Result index(@PathVariable Long page,
                        @PathVariable Long limit,
                        OrderVO orderVO) {
        Page<SysOrder> pageParam = new Page<>(page, limit);

        List<SysOrder> sysOrders = orderService.getPersonalOrder(orderVO,page,limit);

        IPage<SysOrder> pageModel = orderService.page(pageParam);
        pageModel.setRecords(sysOrders);

        return Result.ok(pageModel);
    }

}
